package com.turtle.security.organizates.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.turtle.security.organizates.entity.SysUser;
import com.turtle.security.organizates.mapper.SysUserMapper;
import com.turtle.security.organizates.service.ISysUserService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 系统用户 服务实现类
 *
 * @author turtle
 * @since 2020-05-10
 */
@Service
@AllArgsConstructor(onConstructor = @__(@Autowired))
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService {

    private final SysUserMapper userMapper;

    /**
     * 通过用户账号获取用户信息
     *
     * @param userName 登录账号
     * @return User 用户信息
     */
    @Override
    public SysUser getUserByUsername(String userName) {
        QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(SysUser::getUserName, userName);
        return userMapper.selectOne(queryWrapper);
    }
}
